package org.zfes.snowier.cloud.zbss.cms.router.service.column;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.column.model.CmsColumnUser;
import org.zfes.snowier.cloud.zbss.cms.column.service.ICmsColumnUserService;
@Controller("org.zfes.snowier.cloud.zbss.cms.column.router.service.CmsColumnUserController")  
@RequestMapping("/cms/service/column/cmsColumnUser")
public class CmsColumnUserController extends BaseController {

	
	@Autowired
	private ICmsColumnUserService cmsColumnUserService;
	
	@RequiresPermissions(value="cmsColumnUser:loadCmsColumnUserDataSet",desc="栏目用户订阅列表")
    @RequestMapping(value="/loadCmsColumnUserDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsColumnUserDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsColumnUserService.loadCmsColumnUserDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="cmsColumnUser:createCmsColumnUser",desc="栏目用户订阅添加")
    @RequestMapping(value="/createCmsColumnUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createCmsColumnUser(Long userId,String columnIdMap){
		cmsColumnUserService.createCmsColumnUser(userId,columnIdMap);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsColumnUser:loadCmsColumnUser",desc="栏目用户订阅加载")
    @RequestMapping(value="/loadCmsColumnUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsColumnUser(Long id){
		Optional<CmsColumnUser> ops = cmsColumnUserService.loadCmsColumnUserById(id);
		return ajaxQuery("cmsColumnUser",ops);
    }
	
	@RequiresPermissions(value="cmsColumnUser:updateCmsColumnUser",desc="栏目用户订阅更新")
    @RequestMapping(value="/updateCmsColumnUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCmsColumnUser(CmsColumnUser cmsColumnUser){
		cmsColumnUserService.updateCmsColumnUser(cmsColumnUser);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsColumnUser:deletCmsColumnUser",desc="栏目用户订阅删除")
    @RequestMapping(value="/deleteCmsColumnUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteCmsColumnUser(Long id){
		cmsColumnUserService.deleteCmsColumnUser(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}